/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package xq.gwt.mvc.test;
import java.util.ArrayList;
import xq.gwt.mvc.view.TextPropertyView;
import xq.gwt.mvc.view.ViewChangedListener;

/**
 *
 * @author admin
 */
public class TextPropertyViewMock implements TextPropertyView{
    private String value;
    ArrayList<ViewChangedListener> listeners = new ArrayList<ViewChangedListener>();

    public TextPropertyViewMock(){
        
    }

    public void setText(String text) {
        value = text;
        notifyViewChangedListeners();
    }

    public String getText() {
       return value;
    }

    public void setError(String errorMessage) {

    }

    public void clearError() {

    }

    public void setEnabled(boolean enabled) {
        
    }

    public void setRequired(boolean required) {

    }

    public void addViewChangedListener(ViewChangedListener listener) {
        listeners.add(listener);
    }

    public void removeViewChangedListener(ViewChangedListener listener) {
        listeners.remove(listener);
    }

    protected void notifyViewChangedListeners(){
        for (int i = 0; i < listeners.size(); i++) {
            listeners.get(i).viewChanged();

        }
    }

	@Override
	public void setName(String name) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setTitle(String title) {
		// TODO Auto-generated method stub
		
	}
}
